From 8123a6fe99e01e93b480f036dfee262139e33ae8 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 28 Apr 2024 23:43:57 -0700
Subject: feat(badges): allow awc badges hiding

---
 src/routes/user/[user]/badges/+page.svelte | 68 +++++++++++++++---------------
 1 file changed, 35 insertions(+), 33 deletions(-)

(limited to 'src/routes/user/[user]/badges/+page.svelte')

diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte
index caf2019d..2b7dd65f 100644
--- a/src/routes/user/[user]/badges/+page.svelte
+++ b/src/routes/user/[user]/badges/+page.svelte
@@ -520,42 +520,44 @@
 						!editMode}
 
 					<div id="badges">
-						{#await awcPromise then badges}
-							{#await badges.clone().text() then text}
-								{@const parsedBadges = awcBadgesGrouped(text)}
-
-								{#if parsedBadges.length > 0}
-									{#each parsedBadges as group}
-										<details open={categoryFilter || isOwner ? false : true}>
-											<summary>
-												Anime Watching Club <span class="opaque">|</span>
-												{group.group}
-											</summary>
+						{#if !preferences.hide_awc_badges}
+							{#await awcPromise then badges}
+								{#await badges.clone().text() then text}
+									{@const parsedBadges = awcBadgesGrouped(text)}
+
+									{#if parsedBadges.length > 0}
+										{#each parsedBadges as group}
+											<details open={categoryFilter || isOwner ? false : true}>
+												<summary>
+													Anime Watching Club <span class="opaque">|</span>
+													{group.group}
+												</summary>
+
+												<p />
+
+												<div class="badges">
+													{#each group.badges as badge, index}
+														<div id={`badge-${index}`}>
+															<FallbackBadge
+																{badge}
+																source={cdn(thumbnail(badge.image))}
+																alternative={badge.description}
+																fallback={thumbnail(badge.image)}
+																hideOnError={preferences.hide_missing_badges}
+																awc
+																{index}
+															/>
+														</div>
+													{/each}
+												</div>
+											</details>
 
 											<p />
-
-											<div class="badges">
-												{#each group.badges as badge, index}
-													<div id={`badge-${index}`}>
-														<FallbackBadge
-															{badge}
-															source={cdn(thumbnail(badge.image))}
-															alternative={badge.description}
-															fallback={thumbnail(badge.image)}
-															hideOnError={preferences.hide_missing_badges}
-															awc
-															{index}
-														/>
-													</div>
-												{/each}
-											</div>
-										</details>
-
-										<p />
-									{/each}
-								{/if}
+										{/each}
+									{/if}
+								{/await}
 							{/await}
-						{/await}
+						{/if}
 
 						{#if ungroupedBadges === null}
 							<Message message="Loading badges ..." />
-- 
cgit v1.2.3

